<?php get_header(); ?>	
<?php 
	$isOldVer=true;
	$myparts = $wpdb->get_results( "SELECT id, title FROM wp_movieparts where post_id=".$post->ID );
	if(count($myparts)>0)$isOldVer=false;
?>			
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=622090874530625&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="bg-content"> 

      <!--============================== content =================================-->
  <div class="container">   
	  <div class="breadcrumb-container">
	      <?php if ( function_exists('yoast_breadcrumb') ) {
	yoast_breadcrumb('<p id="breadcrumbs">','</p>');
	} ?>
	</div>      
    <div class="row">
        <article class="span8">
         <div class="inner-1">         
          <ul itemscope="" itemtype="http://schema.org/Article" class="list-blog">
            <li>  
            <h1 itemprop="name">
			
			<?php the_title()?></h1>    
			<?php if(!$isOldVer){
				
              	if(count($myparts)>0){?>
              		<div style="height:20px;"></div>
              		<div><h2 class="normal">Xem phim <?php the_title()?></h2> ở đây:</div><br />
              		<div id="videocontent">
              		<video id="videoframe" class="video-js vjs-default-skin videoframe vjs-big-play-centered" controls preload="none" width="640" height="300">
              			<track  />
              		</video>				  	
				  	<iframe id="videoiframe" width="640" height="300" style="border:none;display:none"></iframe>
				  	
				  	<div id="qualitycontent"></div>
				  	</div>
					<br />
					
					<script>
						var defaultpart=<?php echo $myparts[0]->id?>;
						var hosturl="<?php echo admin_url('admin-ajax.php') ?>";
						//var hosturl="http://test.vn-hd.com:8080/xpct/wp-admin/admin-ajax.php";
						var player,loading,bigplaybutton;
						var isOld="<?php $isOldVer?'true':'false'?>";
						var templateUrl = "<?php echo get_template_directory_uri(); ?>";
					</script>
              		<?php 
              		}              		
              		if(count($myparts)>1){
	              		echo '<div>Tập: ';
	              		foreach($myparts as $k=>$v){
	              			echo '<a href="javascript:changepart('.$v->id.');">'.$v->title.'</a> &nbsp;&nbsp;&nbsp;';
	              		}
	              		echo '</div>';
              		}
              	}
			?>
			
			<br />            
             
              <br />
              <div style="clear:both;"></div>
              <div style="color:#fff">    
              <div>Nếu bạn thấy phim hay thì hãy share nhé :)</div><br />
              <div class="fb-like" data-href="<?php echo the_permalink() ?>" data-layout="button" data-action="like" data-show-faces="false" data-share="true"></div>
				<br />
				<br />
				<br />
				
				<div><h3 class="normal">Nội dung phim <?php the_title()?></h3></div>		
            <?php $imgid=get_post_thumbnail_id(get_the_ID());
            	$imgsrc=wp_get_attachment_image_src($imgid,'full');
            ?>            
            <div class="clear"></div> 
                 <h4>
              <?php echo the_post_thumbnail(array(700,1024),array('alt'=>$post->post_name,title=>get_the_title()));?>              
                    </h4>
            <div style="clear:both;"></div>              
              <div itemprop="description"><?php echo $post->post_content; ?></div> 
              
              <?php if($isOldVer){?>
	              <div>Ngày khởi chiếu: 
	              <?php 
	              		$release=post_custom('release');
		              if(!empty($release)) echo date("d/m/Y",strtotime($release));
		              else echo 'Đang cập nhật';
	              ?>
	              </div>
	              <br />
	              <div>Xem <?php the_title()?> trailer:</div><br />
	              <div>
	              <?php 
	              		$embed=post_custom('embed');
		              if(!empty($embed)):?>
		              	<p><iframe frameborder="0" height="315" src="<?php echo $embed?>" width="560"></iframe> </p>
		           <?php else:?>
		           		Đang cập nhật
		           <?php endif;?>
	              </div>
	              
	              <br />
	              <div>Link download cho phim <?php the_title()?> ở đây:</div>
	              <div>
	              <?php 
	              		$downloadurls=post_custom('download url');
		              if(!empty($downloadurls)):
		              	$arrdownloads=split(',', $downloadurls);
		              	foreach($arrdownloads as $k=>$v):
		              ?>
		              	<a href="<?php echo $v?>"><?php echo substr($v,strrpos($v, '/')+1,strlen($v))?></a><br />
		           <?php endforeach;
		            else:?>
		           		Đang cập nhật
		           <?php endif;?>
	              </div>
	              <br />
	              
	              <div>Subtitle cho phim <?php the_title()?> thì ở đây:</div>
	              <div>
	              <?php 
	              		$subtitles=post_custom('subtitle');
		              if(!empty($subtitles)):
		              	$arrsubtitle=split(',', $subtitles);
		              	foreach($arrsubtitle as $k=>$v):
		              ?>
		              	<a href="<?php echo $v?>"><?php echo substr($v,strrpos($v, '/')+1,strlen($v))?></a><br />
		           <?php endforeach;
		            else:?>
		           		Đang cập nhật
		           <?php endif;?>
	              </div>
              <?php }
              else{
              	//get all part
              	
              }
              ?>
              
              
              
              
		
		</div>
            </li>  
            <?php if(0):  //rating disable ?>
             <li>
             <?php echo the_post_thumbnail(array(150,150),array('title'=>get_the_title(),'itemprop'=>'image'));?>
             <?php wp_gdsr_render_article(49, false,"crystal",12); ?>
             <?php 
             	$linkname=post_custom('link');
             	$linksub=post_custom('subtitle');
             	if(!empty($linkname)){
	            	echo '<h2>'.get_the_title().' download</h2><br /><a title="'.get_the_title().' download" href="'.post_custom('download url').'">'.$linkname.'</a><br />'; 
             	}
             	if(!empty($linksub)){
	            	echo '<a title="'.get_the_title().' subtitle" href="'.$linksub.'">Subtitle</a>'; 
             	}
             ?>
             </li>     
              <?php endif?>  
              
                  
            <li> 
 <?php $catobjs=get_the_category();$cats=array();
 //get child cat
 foreach($catobjs as $k=>$v){
 	$cats[]=$v->cat_ID;
 	//get child cat
 	$childcats=get_categories(array('child_of'=>$v->cat_ID));
 	if(count($childcats)>0){
 		foreach($childcats as $k2=>$v2){
 			$cats[]=$v2->cat_ID;
 		}	
 	}
 }
					 wp_reset_query();
					 //$cat=get_category_by_slug('courses');
					
					 $args = array(
					 	'showposts'=>12,
						'order'=>'DESC',
					 	'category__in'=>$cats,
					 	'post__not_in'=>array(get_the_ID()),
   						'orderby' => 'date'

						);						
					 query_posts($args);
					 		$i=-1;			
	
 ?>
 
 <?php related_posts();?>
              
               
          
            
            </li> 
                                 
          </ul>
          </div>  
        </article>
        <article class="span4">          
          <div class="category-title">Danh mục</div>
          <ul class="list extra extra1">   
          <?php $cats=get_categories();
          	foreach($cats as $k=>$v):
          	if($v->parent==0){
          ?>        
            <li><a title="<?php echo $v->slug?>" href="<?php echo home_url('/category/'.$v->slug.'/')?>"><h3 class="normal"><?php echo $v->name;?></h3></a></li>
            <?php }
            endforeach;?>
                              
      </ul>
          
          
          </div>
        </article>
      </div>
      </div>
  </div>
  
  

    					
<?php get_footer(); ?>